home *** CD-ROM | disk | FTP | other *** search
/ Windows Undocumented File Formats / Windows Undocumented File Formats.img / CHAP10 / LEDUMP.H < prev    next >
Text File  |  1997-07-20  |  4KB  |  172 lines

  1. /**********************************************************************
  2.  *
  3.  * PROGRAM: LEDUMP.H
  4.  *
  5.  * PURPOSE: Header file for LEDUMP.C
  6.  *
  7.  * Copyright 1997, Mike Wallace and Pete Davis
  8.  *
  9.  * Chapter 10, LE File Format, from Undocumented Windows File Formats,
  10.  * published by R&D Books, an imprint of Miller Freeman, Inc.
  11.  *
  12.  **********************************************************************/
  13.  
  14. /* Mini-MZ Header. Need only 2 fields */
  15. typedef struct tagMZHEADER
  16. {
  17.     char    MZMagic[2];
  18.     char    Stuff[58];        /* Stuff we don't care about */
  19.     long    LEOff;
  20. } MZHEADER;
  21.  
  22. /* LE Header structure */
  23. typedef struct tagLEHEADER
  24. {
  25.     char    LEMagic[2];
  26.     BYTE    ByteOrder;
  27.     BYTE    WordOrder;
  28.     DWORD    FormatLevel;
  29.     WORD    CPUType;
  30.     WORD    OSType;
  31.     DWORD    ModuleVer;
  32.     DWORD    ModuleFlags;
  33.     DWORD    NumPages;
  34.     DWORD    EIPObjNum;
  35.     DWORD    EIP;
  36.     DWORD    ESPObjNum;
  37.     DWORD    ESP;
  38.     DWORD    PageSize;
  39.     DWORD    LastPageSize;
  40.     DWORD    FixupSize;
  41.     DWORD    FixupChecksum;
  42.     DWORD    LoaderSize;
  43.     DWORD    LoaderChecksum;
  44.     DWORD    ObjTblOffset;
  45.     DWORD    NumObjects;
  46.     DWORD    ObjPageTbl;
  47.     DWORD    ObjIterPage;
  48.     DWORD    ResourceTbl;
  49.     DWORD    NumResources;
  50.     DWORD    ResNameTable;
  51.     DWORD    EntryTable;
  52.     DWORD    ModDirectTable;
  53.     DWORD    NumModDirect;
  54.     DWORD    FixUpPageTable;
  55.     DWORD    FixUpRecTable;
  56.     DWORD    ImportModTable;
  57.     DWORD    NumImports;
  58.     DWORD    ImportProcTable;
  59.     DWORD    PerPageChecksum;
  60.     DWORD    DataPages;
  61.     DWORD    NumPreloadPages;
  62.     DWORD    NonResTable;
  63.     DWORD    NonResSize;
  64.     DWORD    NonResChecksum;
  65.     DWORD    AutoDSObj;
  66.     DWORD    DebugInfoOff;
  67.     DWORD    DebugInfoLen;
  68.     DWORD    NumInstPreload;
  69.     DWORD    NumInstDemand;
  70.     DWORD    HeapSize;
  71. } LEHEADER;
  72.     
  73. /* Defines for Byte and Word Order */
  74. #define ORD_LITTLEENDIAN    0x00
  75. #define    ORD_BIGENDIAN        0x01
  76.  
  77. /* Defines for CPU Type */
  78. #define CPU_286                0x01
  79. #define CPU_386                0x02
  80. #define CPU_486                0x03
  81.  
  82. /* Defines for OS Type */
  83. #define OS_UNKNOWN            0x00
  84. #define OS_OS2                0x01
  85. #define OS_WINDOWS            0x02
  86. #define OS_DOS4X            0x03
  87. #define OS_WINDOWS386        0x04
  88.  
  89. /* Defines for Module Flags */
  90. #define MOD_PERPROCESSLIBINIT    0x00000004
  91. #define MOD_INTERNALFIXUPS        0x00000010
  92. #define MOD_EXTERNALFIXUPS        0x00000020
  93. #define MOD_INCOMPAT_PM            0x00000100
  94. #define MOD_COMPAT_PM            0x00000200
  95. #define MOD_USES_PM                0x00000300
  96. #define MOD_NOTLOADABLE            0x00002000
  97. #define MOD_MODTYPEMASK            0x00038000
  98. #define MOD_PROGRAMMOD            0x00000000
  99. #define MOD_LIBMOD                0x00008000
  100. #define MOD_PROTLIBMOD            0x00018000
  101. #define MOD_PHYSDEVICEDRVR        0x00020000
  102. #define MOD_VIRTDEVICEDRVR        0x00028000
  103. #define MOD_PERPROCLIBTERM        0x40000000
  104.  
  105.     
  106. /* Object Table Entry Records */
  107. typedef struct tagOBJTBLENTRY
  108. {
  109.     DWORD    VirtualSize;
  110.     DWORD    RelocBaseAddr;
  111.     DWORD    ObjectFlags;
  112.     DWORD    PageTableIndex;
  113.     DWORD    NumPgTblEntries;
  114.     DWORD    Reserved;
  115. } OBJTBLENTRY;
  116.  
  117. /* Defines for Object Flags */
  118. #define OBJ_READABLE        0x0001
  119. #define OBJ_WRITEABLE        0x0002
  120. #define OBJ_EXECUTABLE        0x0004
  121. #define OBJ_RESOURCE        0x0008
  122. #define OBJ_DISCARDABLE        0x0010
  123. #define OBJ_SHARED            0x0020
  124. #define OBJ_PRELOAD            0x0040
  125. #define OBJ_INVALID            0x0080
  126. #define OBJ_ZEROFILLED        0x0100
  127. #define OBJ_RESIDENT        0x0200
  128. #define OBJ_RESIDENTCONTIG    0x0300
  129. #define OBJ_RESIDENTLOCK    0x0400
  130. #define OBJ_RESERVED        0x0800
  131. #define OBJ_1616ALIAS        0x1000
  132. #define OBJ_BIGDEFAULT        0x2000
  133. #define OBJ_CONFORM            0x4000
  134. #define OBJ_PRIVILEGE        0x8000
  135.  
  136.  
  137. /* Object Page Table Entries */
  138. typedef struct tagOBJPAGETBLENTRY
  139. {
  140.     DWORD    PageDataOffset;
  141.     WORD    DataSize;
  142.     WORD    ObjPageFlags;
  143. } OBJPAGETBLENTRY;
  144.  
  145. /* Defines for Object Page Flags */
  146. #define OPG_LEGAL            0x00
  147. #define OPG_ITERATEDDATA    0x01
  148. #define OPG_INVALID            0x02
  149. #define OPG_ZEROFILL        0x03
  150. #define OPG_RANGE            0x04
  151.  
  152.  
  153. typedef struct tagFIXUPREC
  154. {
  155.     BYTE    Src;
  156.     BYTE    Flags;
  157.     WORD    SrcOff_Cnt;
  158. } FIXUPREC;
  159.  
  160. typedef struct tagPROCBYNAME
  161. {
  162.     WORD    ModuleOrd;
  163.     DWORD    ProcNameOff;
  164. } PROCBYNAME;
  165.  
  166. typedef struct tagPROCBYORD
  167. {
  168.     WORD    ModuleOrd;
  169.     WORD    ImportOrd;
  170. };
  171.  
  172.